use mtdb
GO

/* drop/create OBJ_REF_RB */
DROP TABLE OBJ_REF_RB
GO

CREATE TABLE OBJ_REF_RB
(
    RB_ID NUMERIC(16,0),
    TENANT_ID NUMERIC(7,0) NOT NULL,
    OBJ_DEF_ID VARCHAR(128) NOT NULL,
    REF_DEF_ID VARCHAR(128) NOT NULL,
    OBJ_ID VARCHAR(64) NOT NULL,
    OBJ_VER NUMERIC(10,0) DEFAULT 0 NOT NULL,
    TARGET_OBJ_DEF_ID VARCHAR(128) NOT NULL,
    TARGET_OBJ_ID VARCHAR(64) NOT NULL,
    TARGET_OBJ_VER NUMERIC(10,0) DEFAULT 0 NOT NULL
)
GO

CREATE INDEX OBJ_REF_RB_INDEX1 ON OBJ_REF_RB (TENANT_ID, OBJ_DEF_ID, RB_ID)
GO

/* drop/create OBJ_REF_RB */
DROP TABLE OBJ_REF_RB__MTP
GO

CREATE TABLE OBJ_REF_RB__MTP
(
    RB_ID NUMERIC(16,0),
    TENANT_ID NUMERIC(7,0) NOT NULL,
    OBJ_DEF_ID VARCHAR(128) NOT NULL,
    REF_DEF_ID VARCHAR(128) NOT NULL,
    OBJ_ID VARCHAR(64) NOT NULL,
    OBJ_VER NUMERIC(10,0) DEFAULT 0 NOT NULL,
    TARGET_OBJ_DEF_ID VARCHAR(128) NOT NULL,
    TARGET_OBJ_ID VARCHAR(64) NOT NULL,
    TARGET_OBJ_VER NUMERIC(10,0) DEFAULT 0 NOT NULL
)
GO

CREATE INDEX OBJ_REF_RB__MTP_INDEX1 ON OBJ_REF_RB__MTP (TENANT_ID, OBJ_DEF_ID, RB_ID)
GO

/* drop/create OBJ_REF_RB */
DROP TABLE OBJ_REF_RB__USER
GO

CREATE TABLE OBJ_REF_RB__USER
(
    RB_ID NUMERIC(16,0),
    TENANT_ID NUMERIC(7,0) NOT NULL,
    OBJ_DEF_ID VARCHAR(128) NOT NULL,
    REF_DEF_ID VARCHAR(128) NOT NULL,
    OBJ_ID VARCHAR(64) NOT NULL,
    OBJ_VER NUMERIC(10,0) DEFAULT 0 NOT NULL,
    TARGET_OBJ_DEF_ID VARCHAR(128) NOT NULL,
    TARGET_OBJ_ID VARCHAR(64) NOT NULL,
    TARGET_OBJ_VER NUMERIC(10,0) DEFAULT 0 NOT NULL
)
GO

CREATE INDEX OBJ_REF_RB__USER_INDEX1 ON OBJ_REF_RB__USER (TENANT_ID, OBJ_DEF_ID, RB_ID)
GO
